xl: Accept a list for serial in config file
authorWhite, Edmund H <edmund.h.white@intel.com>
Wed, 13 Aug 2014 19:14:07 +0000 (19:14 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 26 Aug 2014 20:15:15 +0000 (21:15 +0100)
Allow the "serial" key to accept a list of serial ports, and pass
them in using the new serial_list domain build element.

For backwards compatibility, still accept singleton values.

Also update the xl.cfg manpage.

This patch borrows substantially from the multiple USB device patch
c3a2148192705592d38407ba9919eb1eb151a153.

Signed-off-by: Ed White <edmund.h.white@intel.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
docs/man/xl.cfg.pod.5
tools/libxl/xl_cmdimpl.c

index 1e04eed0aa15d01364b09825228c5c7ca12cc26c..21ca5025533a1f3dc508ea47eb7192026933dbde 100644 (file)
@@ -1281,13 +1281,15 @@ an usb2 controller. The default is disabled (0).
 
 =over 4
 
-=item B<serial=DEVICE>
+=item B<serial=[ "DEVICE", "DEVICE", ...]>
 
-Redirect the virtual serial port to B<DEVICE>. Please see the
+Redirect virtual serial ports to B<DEVICE>s. Please see the
 B<-serial> option in the L<qemu(1)> manpage for details of the valid
 B<DEVICE> options. Default is B<vc> when in graphical mode and
 B<stdio> if B<nographics=1> is used.
 
+The form serial=DEVICE is also accepted for backwards compatibilty.
+
 =item B<soundhw=DEVICE>
 
 Select the virtual sound card to expose to the guest. The valid
index f1c136a5347c8e07bf5191f3c523b38ff7ef0d17..bdca14b157dfd403c09f8b51b4e1c9a0230e0b54 100644 (file)
@@ -1683,9 +1683,26 @@ skip_vfb:
         if (!xlu_cfg_get_long (config, "spiceusbredirection", &l, 0))
             b_info->u.hvm.spice.usbredirection = l;
         xlu_cfg_get_defbool(config, "nographic", &b_info->u.hvm.nographic, 0);
-        xlu_cfg_get_defbool(config, "gfx_passthru", 
+        xlu_cfg_get_defbool(config, "gfx_passthru",
                             &b_info->u.hvm.gfx_passthru, 0);
-        xlu_cfg_replace_string (config, "serial", &b_info->u.hvm.serial, 0);
+        switch (xlu_cfg_get_list_as_string_list(config, "serial",
+                                                &b_info->u.hvm.serial_list,
+                                                1))
+        {
+
+        case 0: break; /* Success */
+        case ESRCH: break; /* Option not present */
+        case EINVAL:
+            /* If it's not a valid list, try reading it as an atom,
+             * falling through to an error if it fails */
+            if (!xlu_cfg_replace_string(config, "serial",
+                                        &b_info->u.hvm.serial, 0))
+                break;
+            /* FALLTHRU */
+        default:
+            fprintf(stderr,"xl: Unable to parse serial.\n");
+            exit(-ERROR_FAIL);
+        }
         xlu_cfg_replace_string (config, "boot", &b_info->u.hvm.boot, 0);
         xlu_cfg_get_defbool(config, "usb", &b_info->u.hvm.usb, 0);
         if (!xlu_cfg_get_long (config, "usbversion", &l, 0))